//constructors for sending to server

const msgTypes = {
  subscribeToChat: "subscribeToChat",
  sendMessage: "sendMessage",
  reciveMessage: "reciveMessage",
  newUserOnChat: "newUserOnChat",
  requestOnlineList: "onlineList",
  responseOnlineList: "ReciveOnlineList",
};

//subscribe to chat messages
//OUT
function SubscribeToChatMsg(chatID, userName) {
  this.APIType = msgTypes.subscribeToChat;
  this.userName = userName;
  this.chatID = chatID;
}

//send message to chat
//OUT
function SendMessageMsg(chatID, userName, image, message) {
  this.APIType = msgTypes.sendMessage;
  this.chatID = chatID;
  this.userName = userName;
  this.image = image;
  this.message = message;
}

//request onlineList
//OUT
function OnlineListRequest(chatID) {
  this.APIType = msgTypes.requestOnlineList;
  this.chatID = chatID;
}

//recive message from chat
//IN
function ReciveMessageMsg(chatID, date, userName, image, message) {
  this.APIType = msgTypes.reciveMessage;
  this.chatID = chatID ? chatID : "";
  this.userName = userName ? userName : "";
  this.senderKey = "";
  this.timestamp = date ? date : "";
  this.image = image ? image : "";
  this.message = message ? message : "";
}

//new user on chat
//IN
function NewUserOnChatMsg() {
  this.APIType = msgTypes.newUserOnChat;
  this.chatID = "";
  this.userName = "";
}

//response onlineList
//IN
function OnlineListResponse() {
  this.APIType = msgTypes.responseOnlineList;
  this.chatID = "";
  this.onlineList = [];
}

export {
  msgTypes,
  SubscribeToChatMsg,
  SendMessageMsg,
  ReciveMessageMsg,
  NewUserOnChatMsg,
  OnlineListRequest,
  OnlineListResponse,
};
